package com.mxl.springsession;

import com.alibaba.fastjson.support.spring.GenericFastJsonRedisSerializer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.serializer.RedisSerializer;

/**
 * @author MXL
 * @date 2021/9/21 0021
 **/
@SpringBootApplication
public class TestSpringSessionApplication {
    public static void main(String[] args) {
        SpringApplication.run(TestSpringSessionApplication.class, args);
    }

    @Bean
    public RedisSerializer<Object> springSessionDefaultRedisSerializer() {

        // 使用 FastJsonRedisSerializer 来序列化和反序列化 redis 的 value的值
//        FastJsonRedisSerializer<Object> serializer = new FastJsonRedisSerializer<>(Object.class);
//        ParserConfig.getGlobalInstance().addAccept("com.muzz.");
//        ParserConfig.getGlobalInstance().addAccept("org.springframework.");
//        ParserConfig.getGlobalInstance().addAccept("org.springframework.security.core.context.");
//        FastJsonConfig fastJsonConfig = new FastJsonConfig();
//        fastJsonConfig.setCharset(StandardCharsets.UTF_8);
//        serializer.setFastJsonConfig(fastJsonConfig);
//        return serializer;
        return new GenericFastJsonRedisSerializer();
    }
}
